import requests
from fake_useragent import UserAgent
import re
url="https://www.qiushibaike.com/text/page/1/"
# url="https://www.qiushibaike.com/8hr/page/1/"
url="https://www.qiushibaike.com/article/123108863"
headers={
    "User-Agent":UserAgent().random
}
# 构造请求
response=requests.get(url,headers=headers)
info=response.text
# print(info)
infos=re.findall(r'<h1 class="article-title">\s*(.+)\s*</h1>',info)
print(infos)
with open("段子.txt",'a',encoding='utf-8') as f:
    for info in infos:
        f.write(info+"\n\n\n")





